package com.study.service.impl;

import com.study.dao.UserDao;
import com.study.service.UserService;
import org.springframework.beans.factory.InitializingBean;

import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

public class UserServiceImpl implements UserService, InitializingBean {
    public UserServiceImpl(String arg) {
    }

    public UserServiceImpl(){}

    public void destroy() {
        System.out.println("调用销毁方法...");
    }

    public void init() {
        System.out.println("调用init-method初始化方法");
    }

    public void setStrList(List<String> strList) {
        strList.forEach(str -> {
            System.out.println(str);
        });
    }

    @Override
    public void setObjList(List<UserDao> list) {
        list.forEach(obj -> {
            System.out.println(obj);
        });
    }

    //字符串类型的Set集合
    @Override
    public void setValueSet(Set<String> valueSet) {
        valueSet.forEach(str -> {
            System.out.println(str);
        });
    }
    //Bean的Set集合
    @Override
    public void setObjSet(Set<UserDao> objSet) {
        objSet.forEach(obj -> {
            System.out.println(obj);
        });
    }

    @Override
    public void setValMap(Map<String, String> valMap) {
        valMap.forEach((k,v) -> {
            System.out.println(k + "==" + v);
        });
    }
    @Override
    public void setObjMap(Map<String, UserDao> objMap) {
        objMap.forEach((k,v) -> {
            System.out.println(k + "==" + v);
        });
    }

    @Override
    public void setProperties(Properties properties) {
        properties.forEach((k,v) -> {
            System.out.println(k + "==" + v);
        });
    }

    @Override
    public void setUserDao(UserDao userDao) {
        System.out.println(userDao);
    }

    public void afterPropertiesSet() throws Exception {
        System.out.println("调用InitializingBean初始化方法");
    }
}
